package com.soul.server.controller;

import com.soul.model.vo.*;
import com.soul.server.server.SoulService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author mdoya
 * @version 1.0
 * @description:
 */
@Slf4j
@RestController
@RequestMapping("/tanhua")
public class SoulController {

    @Autowired
    private SoulService soulService;

    /**
     *  首页 - 今日佳人
     * @return todayBestVo
     */
    @GetMapping("/todayBest")
    public ResponseEntity findTodayBest(){
        return ResponseEntity.ok(soulService.findTodayBest());
    }

    /**
     *  首页推荐佳人分页
     * @return todayBestVo 对象
     */
    @GetMapping("/recommendation")
    public ResponseEntity findpageRecommendation(RecommendUserVo recommendUserVo){
        return ResponseEntity.ok(soulService.findpageRecommendation(recommendUserVo));
    }

    /**
     *  根据佳人id查询佳人信息
     * @param id 佳人id
     * @return ResponseEntity
     */
    @RequestMapping(path = "/{id}/personalInfo",method = RequestMethod.GET)
    public ResponseEntity findPersonalInfo(@PathVariable("id") String id){
        return ResponseEntity.ok(soulService.findPersonalInfo(id));
    }

    /**
     *  即时通讯-查询陌生人问题
     * @param userId 佳人id
     * @return 字符串
     */
    @RequestMapping(path = "/strangerQuestions",method = RequestMethod.GET)
    public ResponseEntity findStrangerQuestions(String userId){
        return ResponseEntity.ok(soulService.findStrangerQuestions(Long.valueOf(userId)));
    }

    /**
     *  即时通讯-回复陌生人问题(发布陌生人问题)
     * @param params map对象
     * @return null
     */
    @RequestMapping(path = "/strangerQuestions",method = RequestMethod.POST)
    public ResponseEntity addStrangerQuestions(@RequestBody Map<String,String> params){
        Long beautyUserId = Long.valueOf(params.get("userId"));
        String reply = params.get("reply");
        soulService.addStrangerQuestions(beautyUserId,reply);
        return ResponseEntity.ok(null);
    }

    /**
     *   搜索附近的人
     * @param gender 性别
     * @param distance 搜索范围 单位：米
     * @return List<NearUserVo>
     */
    @RequestMapping(path = "/search",method = RequestMethod.GET)
    public ResponseEntity search(String gender,Long distance){
        return ResponseEntity.ok(soulService.searchNearBy(gender,distance));
    }

    /**
     *  探花 - 查询卡片分页列表
     * @return List<TodayBestVo>
     */
    @GetMapping("/cards")
    public ResponseEntity findCards(){
        return ResponseEntity.ok(soulService.findCards());
    }

    /**
     *  探花-喜欢
     * @param likeUserid 佳人id
     * @return
     */
    @GetMapping("/{id}/love")
    public ResponseEntity love(@PathVariable("id") Long likeUserid){
        soulService.love(likeUserid,true);
        return ResponseEntity.ok(null);
    }

    /**
     *  探花-不喜欢
     * @param likeUserid 佳人id
     * @return
     */
    @GetMapping("/{id}/unlove")
    public ResponseEntity unLove(@PathVariable("id") Long likeUserid){
        soulService.love(likeUserid,false);
        return ResponseEntity.ok(null);
    }

}
